package com.qcsec.domain.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.mybatisflex.annotation.*;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.qcsec.common.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Set;

import static com.qcsec.common.consts.CommonCst.KEY_GEN;

@ApiModel
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@Accessors(chain = true)
@Table(value = "sys_role")
public class SysRole extends BaseEntity {
    @Id(keyType = KeyType.Generator, value = KEY_GEN)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    @ApiModelProperty("中文名称")
    private String name;
    @ApiModelProperty("英文名称")
    private String code;

    @ApiModelProperty(value = "选择的菜单ID")
    @RelationOneToMany(
            joinTable = "sys_role_menu",
            joinSelfColumn = "role_id",
            joinTargetColumn = "menu_id",
            selfField = "id", targetField = "id")
    private Set<SysMenu> menus;
}
